package com.jgp.glmeeting.controller;


import com.jgp.glmeeting.model.Manager;
import com.jgp.glmeeting.model.MeetingManagerRelation;
import com.jgp.glmeeting.service.ManagerService;
import com.jgp.glmeeting.service.MeetingManagerRelationService;
import com.jgp.sys.common.controller.JGPController;
import com.jgp.sys.common.pojo.LabelValue;
import com.jgp.sys.ui.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;


@RestController
@RequestMapping("/glMeeting/meetingManagerRelationApiController")
public class MeetingManagerRelationApiController extends JGPController {
    @Autowired
    private ManagerService managerService;

    @Autowired
    private MeetingManagerRelationService meetingManagerRelationService;

   //下拉列表查询所有会议总管
   @RequestMapping("/queryAllManager")
   public Result queryAllManager(Model model, Manager m){
       List<Manager> lists = managerService.queryAll(m);
       List<LabelValue> collect = lists.stream().map(mm ->{
       return new LabelValue(mm.getName(),mm.getId(),null);
      }).collect(Collectors.toList());
       return ajaxRe("ldata",collect);
  }

    /**
     *     添加会议  和   会议总管的关系表
     */
    @RequestMapping("/addMeetingManagerRelation")
    public Result addMeetingManagerRelation(MeetingManagerRelation r){

       meetingManagerRelationService.addMeetingManagerRelation(r);
       return ajaxRe(true);
    }

}
